<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>原料仓库管理系统</title>
</head>
<?php
session_start();
if ($_SESSION['username']!=null){
	
}else{
	 echo"<script type='text/javascript'>location='CKGL-index.php';
			</script>";
}
require('lianjie.php');
?>

<link rel="stylesheet" type="text/css" href="css/daohanglan.css" />
<link rel="stylesheet" type="text/css" href="css/tou.css" />
<link rel="stylesheet" type="text/css" href="css/ckgl_rk.css" />
<script type="text/javascript" src="js/tuichuDL.js">
</script>
<body background="" style="background-repeat:no-repeat;
               background-attachment:fixed;
               background-size:100% 100%;">
<div class="box">
<header>

<h2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;原料仓库管理系统</h2>
</header>
<div class="YH"><p><?php echo $_SESSION['username'];?><input type="button" name="bt1" onclick="c1()" value="退出" /></p></div>
<div class="box_DH">
<ul>

    <li><a href="CKGL_no1.php">logo</a></li>
    <li><a href="CKGL_no1.php">首页</a></li>
    <li><a href="CKGL_cksj.php">查看数据</a></li>
    <li><a href="CKGL_cw.php">查看储位</a></li>
    <li><a href="CKGL_rk.php">入库</a>
    </li>
    <li><a href="CKGL_ck.php">出库</a>
    </li>
    <li><a href="CKGL_zk.php">转库</a>
    </li>
    <li><a href="CKGL_plupdata.php">批量修改</a>
    </li>
    <li><a>生成报表</a>
    	<ul>
        	<li><a href="CKGL_zdy.php">生成自定义表</a></li>
            <li><a href="CKGL_rbb.php">生成一般报表</a></li>
    	</ul>
     </li>
</ul>
</div>
<div class="box_WBK">
<form name="WBK_from" action="rk_ok.php" method="post"><textarea name="WBK_text" value="" style="width:710px; height:260px;"></textarea><br />&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" name="WBK_sub" value="确认输入" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" name="WBK_res" value="清空内容" /></form>
</div>

<div class="box_RRKJL">
<h2 align="center" style="color:#F00">入库</h2>
<table>
<tr><td>今日入库记录</td></tr>
<tr>
<td align="center">原料名称</td>
<td align="center">入库量（KG）</td>
</tr>
<?php

if(mysqli_select_db($connID,$dbName)){
	$sql="select name,SW from RKB where dh_date='".date('Y-m-d')."';";
	$sqlPD="select count(*) from RKB where dh_date='".date('Y-m-d')."';";
	$resultPD=mysqli_query($connID,$sqlPD);
	$myrowPD=mysqli_fetch_array($resultPD);
	$result=mysqli_query($connID,$sql);
	if($myrowPD[0]>=1){
		while($myrow=mysqli_fetch_array($result)){	
?>
<tr>
    <td align="center"><span class="STYLE2"><?php echo $myrow[0];?></span></td>
    <td align="center"><span class="STYLE2"><?php echo $myrow[1];?></span></td>
</tr>
<?php 
		}
	}
	else{
?>
<tr>
	<td align="center"><span class="STYLE2"><?php echo "暂无数据";?></span></td>
    <td align="center"><span class="STYLE2"><?php echo "暂无数据";?></span></td>
</tr>
<?php 
	}
}
?>
</table>
</div>
<div class="box_RKTS">
<table style="width:100%;">
<tr><td>今日结存记录</td></tr>
<tr>
<td align="center">时间</td>
<td align="center">名称</td>
<td align="center">批号</td>
<td align="center">手册号</td>
<td align="center">结存数量</td>
</tr>
<?php
if(mysqli_select_db($connID,$dbName)){
	$sqltsr="select r.dh_date,r.name,r.PH,r.id,r.SW,c.s from (select dh_date,name,PH,id,KQ,sum(BS) as BS,sum(SW) as SW,sum(GU) as GU,sum(NIE) as NIE,sum(MENG) as MENG,sum(TONG) as TONG,sum(LI) as LI,BLB,YLLB,LY,LBLB from rkb group by name,PH,id) as r left join (select name,PH,id,sum(SW) as s,sum(BS) as b,QX from ckb where dh_date>='".date('Y-m-d',strtotime('-2 day'))."' and dh_date<='".date('Y-m-d')."' group by name,PH,id) as c on r.PH=c.PH and r.name=c.name and r.id=c.id where (r.dh_date='".date('Y-m-d',strtotime('-2 day'))."' or r.dh_date='".date('Y-m-d',strtotime('-1 day'))."' or r.dh_date='".date('Y-m-d')."');"/*"where rkb.dh_date>='".date('Y-m-d',strtotime("-1 week"))."' and rkb.dh_date<='".date('y-m-d')." and ckb.dh_date>='".date('Y-m-d',strtotime("-1 week"))."' and ckb.dh_date<='".date('y-m-d')."';"*/;
	
	$sqltsPD="select count(*) from rkb where dh_date>='".date('Y-m-d',strtotime("-2 day"))."' and dh_date<='".date('y-m-d')."';";
	$resulttsPD=mysqli_query($connID,$sqltsPD);
	$myrowtsPD=mysqli_fetch_array($resulttsPD);
	$resultts=mysqli_query($connID,$sqltsr);
	if($myrowtsPD[0]>=1){
		while($myrow=mysqli_fetch_array($resultts)){	
?>
<tr>
    <td align="center"><span class="STYLE2"><?php echo $myrow[0];?></span></td>
    <td align="center"><span class="STYLE2"><?php echo $myrow[1];?></span></td>
    <td align="center"><span class="STYLE2"><?php echo $myrow[2];?></span></td>
    <td align="center"><span class="STYLE2"><?php echo $myrow[3];?></span></td>
    <td align="center"><span class="STYLE2"><?php echo $myrow[4]-$myrow[5];?></span></td>
</tr>
<?php 
		}
	}
	else{
?>
<tr>
	<td align="center"><span class="STYLE2"><?php echo "暂无数据";?></span></td>
    <td align="center"><span class="STYLE2"><?php echo "暂无数据";?></span></td>
    <td align="center"><span class="STYLE2"><?php echo "暂无数据";?></span></td>
    <td align="center"><span class="STYLE2"><?php echo "暂无数据";?></span></td>
    <td align="center"><span class="STYLE2"><?php echo "暂无数据";?></span></td>
</tr>
<?php 
	}
}
?>
</table>
</div>
</div>
</body>
</html>